import { ApolloProvider } from '@apollo/client'
import makeClient from './libs/apollo-client'
import { HashRouter, Route, Routes } from 'react-router'
import NotFoundPage from './pages/404'
import { ConfigProvider } from 'antd'
import zhCN from 'antd/locale/zh_CN';
import 'dayjs/locale/zh-cn';
import AdminLayout from './pages/admin/layout'
import AdminPage from './pages/admin/page'
import HomeLayout from './pages/layout'
import HomePage from './pages/page'
import AdminLoginPage from './pages/admin/login/page'
import AdminInitPage from './pages/admin/init/page'
import AdminSystemRolePage from './pages/admin/system/role/page'
import AdminSystemRoleActionPage from './pages/admin/system/role/action/page'
import AdminSystemUsersPage from './pages/admin/system/users/page'
import AdminNoticePage from './pages/admin/notices/page'
import AdminNoticeAction from './pages/admin/notices/action/page'
import AdminPartnerPage from './pages/admin/partner/page'
import AdminSoftwarePage from './pages/admin/software/page'
import AdminOutlinePage from './pages/admin/outline/page'
import NoticePage from './pages/notice/page'
import SoftwarePage from './pages/software/page'
import PartnerPage from './pages/partners/page'
import AdminTestPage from './pages/admin/test/page'
import AdminTestGroupPage from './pages/admin/test/group/page'
import AdminTestGroupChapterPage from './pages/admin/test/group/chapter/page'
import AdminTesgroupChapterPaperPage from './pages/admin/test/group/chapter/paper/page'
import AdminQuestionPage from './pages/admin/question/page'
import AuthLoginPage from './pages/auth/login/page'
import AuthUserRegisterPage from './pages/auth/userRegister/page'
import AuthOrganRegisterPage from './pages/auth/organRegister/page'
import AuthForgotPage from './pages/auth/forgot/page'
import AdminWebsitePage from './pages/admin/website/page'
import TestPage from './pages/test/page'
import { CurrentHeaderProvider } from './hooks/usePath'
import TestGroupPage from './pages/test/group/page'
import TestGroupChapterPage from './pages/test/group/chapter/page'
import TestGroupChapterPaperPage from './pages/test/group/chapter/paper/page'
import AdminFeedbackPage from './pages/admin/feedback/page'
import AboutPage from './pages/about/page'
import ExamsPage from './pages/exams/page'
import AdminOrderPage from './pages/admin/order/page'

function App() {
  const client = makeClient()
  return (
    <CurrentHeaderProvider>
      <ConfigProvider locale={zhCN}>
        <ApolloProvider client={client}>
          <HashRouter>
            <Routes>
              <Route element={<HomeLayout />}>
                <Route path='/' element={<HomePage />} />
                <Route path='/:type/notice' element={<NoticePage />} />
                <Route path='/software' element={<SoftwarePage />} />
                <Route path='/partners' element={<PartnerPage />} />
                <Route path='/auth/login' element={<AuthLoginPage />} />
                <Route path='/auth/userRegister' element={<AuthUserRegisterPage />} />
                <Route path='/auth/organRegister' element={<AuthOrganRegisterPage />} />
                <Route path='/auth/forgot' element={<AuthForgotPage />} />
                <Route path='/test' element={<TestPage />} />
                <Route path='/test/:groupId/group' element={<TestGroupPage />} />
                <Route path='/test/:groupId/group/:testId/chapter' element={<TestGroupChapterPage />} />
                <Route path='/test/:groupId/group/:testId/chapter/:chapterId/paper/:paperId/questions' element={<TestGroupChapterPaperPage />} />
                <Route path='/exams' element={<ExamsPage />} />
                <Route path='/about' element={<AboutPage />} />
                <Route path='*' element={<NotFoundPage />} />
              </Route>
              <Route path='/admin/login' element={<AdminLoginPage />} />
              <Route path='/admin/init' element={<AdminInitPage />} />
              <Route path='/admin' element={<AdminLayout />}>
                <Route path='' element={<AdminPage />} />
                <Route path='system/role' element={<AdminSystemRolePage />} />
                <Route path='system/role/action' element={<AdminSystemRoleActionPage />} />
                <Route path='system/users' element={<AdminSystemUsersPage />} />
                <Route path='order' element={<AdminOrderPage />} />
                <Route path='notices' element={<AdminNoticePage />} />
                <Route path='notice/action' element={<AdminNoticeAction />} />
                <Route path='partner' element={<AdminPartnerPage />} />
                <Route path='software' element={<AdminSoftwarePage />} />
                <Route path='outline' element={<AdminOutlinePage />} />
                <Route path='website' element={<AdminWebsitePage />} />
                <Route path='feedback' element={<AdminFeedbackPage />} />
                <Route path='test' element={<AdminTestPage />} />
                <Route path='test/:groupId/group' element={<AdminTestGroupPage />} />
                <Route path='test/:groupId/group/:testId/chapter' element={<AdminTestGroupChapterPage />} />
                <Route path='test/:groupId/group/:testId/chapter/:chapterId/paper' element={<AdminTesgroupChapterPaperPage />} />
                <Route path='question' element={<AdminQuestionPage />} />
              </Route>
            </Routes>
          </HashRouter>
        </ApolloProvider >
      </ConfigProvider>
    </CurrentHeaderProvider>
  )
}

export default App
